<template>
    <div>
<h2 align="center">登录页面</h2>
<table class="table table-bordered" >
    <tbody>
        <tr align="center">
            <td>用户名</td>
            <td>
                <input type="text" v-model="state.Name" >
            </td>
        </tr>

        <tr align="center">
            <td>密码</td>
            <td>
                <input type="password" v-model="state.Pwd" >
            </td>
        </tr>

        <tr align="center">
           
            <td colspan="2">
                <input type="button" value="登录" @click="Login">
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs} from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router=useRouter();

let data=reactive({
    state:{
        Name:'',
        Pwd:'',
    }
});

let {state}=toRefs(data);
const Login=()=>{

    if(state.value.Name=="")
{
    alert("用户名不能为空")
    return;
}

if(state.value.Pwd=="")
{
    alert("密码不能为空")
    return;
}

let obj={
    Name:state.value.Name,
    Pwd:state.value.Pwd,
};


axios({
    url:'https://localhost:7284/api/Login/GetLogin/GetLogin',
    method:'get',
    params:obj,
})

.then((res)=>{
    if(res.data.data!=null)
{
    alert("登录成功")
    router.push('/memberadd')
}
else
{
    alert("用户信息错误")
    return;
    
}
})

}
</script>

<style scoped>

</style>